
from selenium.webdriver.common.by import By

from homework.homework_my.po.base_page import BasePage



class AddMemberPage(BasePage):
    _base_url = "https://work.weixin.qq.com/wework_admin/frame#contacts"
    user_name = (By.ID, "username")
    user_password = (By.ID, "memberAdd_acctid")
    user_phone = (By.ID, "memberAdd_phone")

    def add_member(self,name):
        from homework.homework_my.po.contact_page import ContactPage
        self.find(self.user_name).send_keys(name)
        self.find(self.user_password).send_keys("12345")
        self.find(self.user_phone).send_keys("18871680043")
        self.driver.find_element(By.CSS_SELECTOR, ".js_btn_save").click()
        return ContactPage(self.driver)

    def add_member_fail(self,name):
        from homework.homework_my.po.contact_page import ContactPage
        self.find(self.user_name).send_keys(name)
        self.find(self.user_password).send_keys("12345")
        self.find(self.user_phone).send_keys("18871680043")
        self.driver.find_element(By.CSS_SELECTOR, "js_btn_cancel").click()
        return ContactPage(self.driver)